import hasPermi from './hasPermi.js';
import User from '@/store/user.js';
import Dict from '@/store/dict.js';
import Com from '@/store/com.js';

export default {
	install(App) {
		uni['$store'] = App.config.globalProperties.$store = {
			user: User(),
			dict: Dict(),
			com: Com()
		};
		App.directive('hasPermi', hasPermi);
		/**
		 * vite动态加载图片静态文件
		 * @param {string} path 文件路径
		 * @returns
		 */
		const modules = import.meta.glob('../static/img/**/*', {
			eager: true
		});
		App.config.globalProperties.getImgUrl = (path) => {
			if (path && modules) {
				if (path.includes('../static/img/')) {
					return modules[path]?.default;
				} else {
					return modules[`../static/img/${path}`]?.default;
				}
			}
		};
	},
};